package io.ydjs.api.app.login.controller;

import io.ydjs.api.app.auth.request.PasswordLoginRequest;
import io.ydjs.api.app.auth.response.LoginResponse;
import io.ydjs.common.annotation.Login;
import io.ydjs.common.api.Result;
import io.ydjs.service.login.AppLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户注册Api
 */
@RestController
@RequestMapping("/app/login")
@Api(tags = "用户注册Api")
public class AppLoginController {
    private final AppLoginService appLoginService;

    public AppLoginController(AppLoginService appLoginService) {
        this.appLoginService = appLoginService;
    }

    /**
     * 用户注册
     * @param request 用户信息
     * @return 登录信息
     */
    @Login
    @PostMapping("/info")
    @ApiOperation("用户注册")
    public Result<LoginResponse> userInfo(@RequestBody PasswordLoginRequest request){
        LoginResponse loginResponse= appLoginService.info(request);
        return new Result<LoginResponse>().ok(loginResponse);
    }

}
